<!DOCTYPE html>
<html lang="">
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>Edit Blog</title>

		<!-- Bootstrap CSS --><link rel="stylesheet" type="text/css" href="/css/bootstrap.min.css">
		
		
		<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
		<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
		<!--[if lt IE 9]>
			<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.2/html5shiv.min.js"></script>
			<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
		<![endif]-->
	</head>
	<body>
		<div class="container">
			<%- include('../head.ejs')%>
				
			<div style="padding-top:0;">
				<div class="panel panel-success text-center">
					<div class="panel-heading">
						<h1 class="panel-title">Blog Edit</h1>
					</div>
					<div class="panel-body">
						<form action="/blog/edit" method="POST" role="form">
							<input type="hidden" name="_id" id="_id" class="form-control" value="<%= _id%>">
							<input type="hidden" name="user_id" id="user_id" class="form-control" value="<%= user._id%>">					
							<div class="form-group">
								<label for="title">Blog Title</label>
								<input value="<%= title%>" type="text" class="form-control" id="title" name="title" placeholder="Input Blog Title">
							</div>

							<div class="form-group">
								<label for="author">Blog Author</label>
								<input value="<%= author%>" type="text" class="form-control" id="author" name="author" placeholder="Input Blog Author">
							</div>

							<div class="form-group">
								<label for="tags">Blog Tags</label>
								<input value="<%= tags%>" type="text" class="form-control" id="tags" name="tags" placeholder="Input Blog Tags,Please Use [,] split">
							</div>

							<div class="form-group">
								<label for="keywords">Blog Keywords</label>
								<input value="<%= keywords%>"  type="text" class="form-control" id="keywords" name="keywords" placeholder="Input Blog keywords,Please Use [,] split">
							</div>
							<div class="form-group">
								<label for="zhaiyao">Blog Zhaiyao</label>
								<textarea name="zhaiyao" id="zhaiyao" class="form-control" rows="3" placeholder="Input Blog zhaiyao"><%= zhaiyao%></textarea>
							</div>
							<div class="form-group">
								<label for="content">Blog Content</label>
								<textarea name="content" id="content" class="form-control" rows="3" placeholder="Input Blog content"><%= content%></textarea>
							</div>
							<button type="submit" id="btn_submit" class="btn btn-success btn-block">Submit</button>
						</form>
					</div>
				</div>
			</div>
			<%- include('../footer.ejs')%>
		</div>
		<script type="text/javascript" src="/js/jquery-1.10.2.js"></script>
		<!-- Bootstrap JavaScript -->
		<script type="text/javascript" src="/js/bootstrap.min.js"></script>
		<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
		<script src="/js/ckEditor/ckeditor.js" type="text/javascript"></script>
		<script type="text/javascript" charset="utf-8">
			function yanzheng(){
				if($('#title').val() == '' || $('#title').val() == null){
					$('#title').focus();
					return false;
				}

				if($('#author').val() == '' || $('#author').val() == null){
					$('#author').focus();
					return false;
				}

				if($('#tags').val() == '' || $('#tags').val() == null){
					$('#tags').focus();
					return false;
				}

				if($('#keywords').val() == '' || $('#keywords').val() == null){
					$('#keywords').focus();
					return false;
				}

				if($('#zhaiyao').val() == '' || $('#zhaiyao').val() == null){
					$('#zhaiyao').focus();
					return false;
				}
				return true;
			}
			var content = document.getElementById("content");
			var editor = CKEDITOR.replace(content,{
				toolbar:[
					['Source','-','Preview','-','Templates'],     
				    ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],     
				    ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],     
				    ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],     
				    ['BidiLtr', 'BidiRtl'],
				    ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],     
				    ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],     
				    ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],     
				    ['Link','Unlink','Anchor'],     
				    ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],
				    ['Styles','Format','Font','FontSize'],     
				    ['TextColor','BGColor'],     
				    ['Maximize', 'ShowBlocks','-','About'] 
				]
			});
			editor.on("instanceReady", function (evt) {  
				editor.addCommand("save", {
					modes: { wysiwyg: 1, source: 1 }, exec: function (editor) {  
						return yanzheng();
					} 
				});  
			});  
			$('#btn_submit').on('click', function() {
				return yanzheng()
			});

			$(function() {
			    $('.navEditBlog').addClass('active');
			});
		</script>
	</body>
</html>